import os
import time
import threading

from CoTec.core.log.log_go import LogGo

# class general(object):
#     pass
#
#     @staticmethod


class killer(threading.Thread):
    # kill_command = 'ps aux|grep python|grep -v grep|cut -c 9-15|xargs kill -15'
    # wd = os.getcwd()
    # kill_command = 'sh ' + 'shutdown.sh'
    # kill_command = '/root/Mario/Xeno2/shutdown.sh'

    def __init__(self,rootpath, millisceond, pid=None):
        super().__init__()
        self.daemon = True
        self.pid = pid
        self.millisecond = millisceond
        self.kill_command = rootpath + 'shutdown.sh'

    def run(self):
        time.sleep(self.millisecond)

        if self.pid == None:
            LogGo.warning(">>>>>>>>>>>>>>>>> I killed myself!!! >>>>>>>>>>>>>>>>>")
            os.system(self.kill_command)
